package com.tanhua.server.controller;

import com.tanhua.domain.vo.NearUserVo;
import com.tanhua.domain.vo.PageResult;
import com.tanhua.domain.vo.RecommendUserQueryParam;
import com.tanhua.domain.vo.RecommendUserVo;
import com.tanhua.server.service.RecommendUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class RecommendUserController {
    @Autowired
    private RecommendUserService recommendUserService;
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
      RecommendUserVo recommendUserVo= recommendUserService.todayBest();
      return ResponseEntity.ok(recommendUserVo);
    }
    @GetMapping("/recommendation")
    public ResponseEntity recommendList( RecommendUserQueryParam recommendUserQueryParam){
      PageResult<RecommendUserVo> pageResult =recommendUserService.recommendList(recommendUserQueryParam);
      return ResponseEntity.ok(pageResult);
    }
    @GetMapping("/{personId}/personalInfo")
    public ResponseEntity<RecommendUserVo> personalInfo(@PathVariable String personId){
     RecommendUserVo userVo=   recommendUserService.personalInfo(personId);
        return ResponseEntity.ok(userVo);
    }
    @GetMapping("/strangerQuestions")
    public ResponseEntity getStrangerQuestions(Long userId){
     String question= recommendUserService.getStrangerQuestions(userId);
        return ResponseEntity.ok(question);
    }
    @PostMapping("/strangerQuestions")
    public ResponseEntity postStrangerQuestions(@RequestBody Map<String,Object> param){
        recommendUserService.postStrangerQuestions(param);
        return ResponseEntity.ok(null);
    }
    @GetMapping("/search")
    public ResponseEntity searchUser( String gender, Long distance){
       List<NearUserVo> nearUserVos= recommendUserService.search(gender,distance);
       return ResponseEntity.ok(nearUserVos);
    }
}
